Component({
  properties: {
    checked: {
      type: Boolean,
      value: false,
    },
    size: {
      type: String,
      value: "1em",
    },
  },

  data: {
    isChecked: false,
  },
  observers: {
    checked(newVal) {
      this.setData({
        isChecked: newVal,
      });
    },
  },
  attached() {
    this.setData({
      isChecked: this.data.checked,
    });
  },
  methods: {
    // onChange(e) {
    //   const { value } = e.detail;
    //   this.triggerEvent("change", !!value.length);
    // },
    toggleChecked() {
      const isChecked = !this.data.isChecked;
      this.setData({
        isChecked,
      });
      this.triggerEvent("change", isChecked);
    },
  },
});
